﻿//去除空格
function StringHelper(){}

StringHelper.trim = function(s)
{
	s += "";
	return s.replace(/^\s+|\s+$/g,'');
}
//文本框变色
function setTxt(id)
    {
       document.getElementById(id).style.backgroundColor="#FFF7E4";
    }
   function setTxtBlue(id)
        {
            document.getElementById(id).style.backgroundColor="white";
        }
//输入框输入的是数字
function shuzi()
{
    if ((event.keyCode < 48 || event.keyCode > 57) &&  event.keyCode != 46) event.returnValue = false;
}
function Showpage(orderNo,version)
{
window.self.location.href='SAdvanceAccountApplyLink.aspx?advNo='+orderNo+'&version='+version;
}
function Showpage1(orderNo,version)
{
window.self.location.href='SExpenseAccountApply.aspx?EACode='+orderNo+'&version='+version;
}
//用户信息
function _trimUser()
{ 
	document.getElementById("txtLogin").value = StringHelper.trim(document.getElementById("txtLogin").value);
	document.getElementById("txtName").value = StringHelper.trim(document.getElementById("txtName").value);
	document.getElementById("txtPwd").value = StringHelper.trim(document.getElementById("txtPwd").value);
	document.getElementById("txtCode").value = StringHelper.trim(document.getElementById("txtCode").value);
    //document.getElementById("txtSure").value = StringHelper.trim(document.getElementById("txtSure").value);
    document.getElementById("txtEmail").value = StringHelper.trim(document.getElementById("txtEmail").value);
}
function validationUser()
{
 _trimUser();
  if(document.activeElement.id=="cmdAdd")
  {
    if (document.getElementById('txtCode').value =="")
    {
      alert("请输入员工编号！");
      document.getElementById('txtCode').focus();
      return false;
    }   
    if (document.getElementById('txtLogin').value =="")
    {
      alert("请输入用户名！");
      document.getElementById('txtLogin').focus();
      return false;
    }    
    if (document.getElementById('txtName').value =="")
    {
      alert("请输入中文名！");
      document.getElementById('txtName').focus();
      return false;
    } 
   if (document.getElementById('txtPwd').value =="")
    {
      alert("请输入密码！");
      document.getElementById('txtPwd').focus();
      return false;
    }  
      if (document.getElementById('txtSure').value =="")
    {
      alert("请输入确认密码！");
      document.getElementById('txtSure').focus();
      return false;
    } 
    if(document.getElementById('txtPwd').value !=document.getElementById('txtSure').value)   
   {
      alert("密码不一致");
      document.getElementById('txtPwd').focus();
      return false;
   }  
   return true;
  }
  else
  {
    return true;
  }
 }
function ClearUser()
{
     document.getElementById('txtName').value="";  
     document.getElementById('txtLogin').value=""; 
     document.getElementById('txtPwd').disabled=false;
     document.getElementById('txtPwd').value=""; 
     document.getElementById('txtSure').value="";
     document.getElementById('txtSure').disabled=false; 
     document.getElementById('txtNo').value=""; 
     document.getElementById('txtLevel').value=""; 
     document.getElementById('txtEname').value=""; 
     document.getElementById('txtLegal').value=""; 
     document.getElementById('txtEmail').value="";  
     document.getElementById('uploadFile').value="";
     document.getElementById('ddlAcc').selectedIndex=0;
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
     document.getElementById('txtLogin').focus();
     var panel=document.getElementById('imageSign');    
     if(panel)
     {    
       if(panel.style.display=='none')
       {    
         //panel.style.display='block';    
       }
       else
       {    
         panel.style.display='none';    
       }    
    }
} 
//个人资料更改
function _trimPersonalUser()
{ 
	document.getElementById("txtName").value = StringHelper.trim(document.getElementById("txtName").value);
    document.getElementById("txtEmail").value = StringHelper.trim(document.getElementById("txtEmail").value);
}
function validationPersonalUser()
{
 _trimPersonalUser();
  if(document.activeElement.id=="cmdSave")
  {
    if (document.getElementById('txtNo').value =="")
    {
      alert("请输入员工编号-Please enter your NO.！");
      document.getElementById('txtNo').focus();
      return false;
    }   
    if (document.getElementById('txtLogin').value =="")
    {
      alert("请输入用户名-Please enter your User Name！");
      document.getElementById('txtLogin').focus();
      return false;
    }    
    if (document.getElementById('txtName').value =="")
    {
      alert("请输入中文名-Please enter your CHN Name！");
      document.getElementById('txtName').focus();
      return false;
    } 
   if (document.getElementById('txtEmail').value =="")
    {
      alert("请输入邮箱-Please enter your Email address！");
      document.getElementById('txtPwd').focus();
      return false;
    }  
   return true;
  }
  else
  {
    return true;
  }
 }
//经理与用户关联
 function _trim1()
{
	document.getElementById("txtName").value = StringHelper.trim(document.getElementById("txtName").value);
	document.getElementById("txtNormal").value = StringHelper.trim(document.getElementById("txtNormal").value);
}
function validation1()
{
 _trim1();
  if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit")
  {

    if (document.getElementById('txtName').value =="")
    {
      alert("请输入经理编号！");
      document.getElementById('txtName').focus();
      return false;
    }    
     if (document.getElementById('txtNormal').value =="")
    {
      alert("请输入用户编号！");
      document.getElementById('txtNormal').focus();
      return false;
    }    
    return true;
  }
  else
  {
    return true;
  }
}
function Clear1()
{
     document.getElementById('txtName').value="";  
     document.getElementById('txtNormal').value="";   
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
     document.getElementById('txtName').focus();
}
//预支单
 function _trimOrder()
{
	document.getElementById("txtReason").value = StringHelper.trim(document.getElementById("txtReason").value);
	document.getElementById("txtAdvAbs").value = StringHelper.trim(document.getElementById("txtAdvAbs").value);
	document.getElementById("txtAmount").value = StringHelper.trim(document.getElementById("txtAmount").value);
}
function validationOrder()
{
 _trimOrder(); 
  if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit"||document.activeElement.id=="cmdSave"||document.activeElement.id=="cmdEditSave")
  {
    if (document.getElementById('txtReason').value =="")
    {
      alert("请输入申请原因-Please enter your reason!");
      document.getElementById('txtReason').focus();
     showclose('doing');showclose('dosing');  
      return false;
    }
       if(document.getElementById('ddlHDep').selectedIndex==0)
   {
      alert("请选择审核部门-Please select your Cost Center!");
      document.getElementById('ddlHDep').focus();
     showclose('doing');showclose('dosing');  
      return false;
   }    
         if(document.getElementById('ddlPT').selectedIndex==0)
   {
      alert("请选择付款方式-Please select your payment type!");
     showclose('doing');showclose('dosing');  
      document.getElementById('ddlPT').focus();
      return false;
   }  
    if (document.getElementById('txtTotal').value =="0")
    {
      alert("请填写金额-Please enter your amount!");
      showclose('doing');showclose('dosing');  
      return false;
    }
    if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit")
    { 
        if(window.confirm("确定?\rAre you sure?"))
        {
                return true;
        }  
        else
        {
                showclose('doing');showclose('dosing');
                return false;
         }
    }
    return true;
  }
  else if(document.activeElement.id=="cmdDTAdd")
  {
    if(document.getElementById('ddlET').selectedIndex==0)
   {
      alert("请选择费用类型-Please select your expense type!");
      showclose('doing');showclose('dosing'); 
      document.getElementById('ddlET').focus();
      return false;
   }   
    if (document.getElementById('txtAdvAbs').value =="")
    {
      alert("请输入摘要-Please enter your abstract!");
     showclose('doing');showclose('dosing');  
      document.getElementById('txtAdvAbs').focus();
      return false;
    }
   	var reg = /^-?\d*(\.)?\d+$/;
    var str=document.getElementById('txtAmount').value;
    var str1=document.getElementById('txtRate').value; 
    if(arr=str.match(reg))
    {
      		//return true;
   	}
   	else
   	{
     		alert("金额输入有误-Error format!");
     		 showclose('doing');showclose('dosing'); 
     		document.getElementById('txtAmount').focus();
      		return false;
   	}
    if(arr=str1.match(reg))
    {
      		return true;
   	}
   	else
   	{
     		alert("汇率输入有误-Error format!");
     		showclose('doing');showclose('dosing'); 
     		document.getElementById('txtRate').focus();
      		return false;
   	}	
//    if (document.getElementById('txtAmount').value =="")
//    {
//      alert("请输入金额!");
//      document.getElementById('txtAmount').focus();
//      return false;
//    }
    return true;
  }
  else
  {
    return true;
  }
}
function validationAuditOrder()
{
//  if(document.activeElement.id=="cmdDTAdd")
//  {
    if(document.getElementById('ddlET').selectedIndex==0)
   {
      alert("请选择费用类型-Please select your expense type!");
      //showclose('doing');showclose('dosing'); 
      document.getElementById('ddlET').focus();
      return false;
   }   
    if (document.getElementById('txtAdvAbs').value =="")
    {
      alert("请输入摘要-Please enter your abstract!");
      //showclose('doing');showclose('dosing');  
      document.getElementById('txtAdvAbs').focus();
      return false;
    }
   	var reg = /^-?\d*(\.)?\d+$/;
    var str=document.getElementById('txtAmount').value;
    if(arr=str.match(reg))
    {
      		return true;
   	}
   	else
   	{
     		alert("输入有误-Error format!");
     		//showclose('doing');showclose('dosing'); 
     		document.getElementById('txtAmount').focus();
      		return false;
   	}
    return true;
//  }
//  else
//  {
//    return true;
//  }
}
//修改密码
 function _trimPwd()
{
	document.getElementById("txtPwd").value = StringHelper.trim(document.getElementById("txtPwd").value);
	document.getElementById("txtPwd1").value = StringHelper.trim(document.getElementById("txtPwd1").value);
	document.getElementById("txtPwd2").value = StringHelper.trim(document.getElementById("txtPwd2").value);
}

function validationPwd()
{
 _trimPwd();
  if(document.activeElement.id=="cmdEdit")
  {
    if (document.getElementById('txtPwd').value ==""||document.getElementById('txtPwd1').value ==""||document.getElementById('txtPwd2').value =="")
    {
      alert("必填项不能为空");
      document.getElementById('txtPwd').focus();
      return false;
    }
   else if(document.getElementById('txtPwd1').value !=document.getElementById('txtPwd2').value)    {
      alert("新密码不一致");
      document.getElementById('txtPwd1').focus();
      return false;
   } 
   else
    {return true;}
  }
  else
  {
    return true;
  }
}
function ClearPwd()
{
     document.getElementById('txtPwd').value="";  
     document.getElementById('txtPwd1').value="";  
     document.getElementById('txtPwd2').value="";  
     document.getElementById('txtPwd').focus();
}
//支付通知
 function _trimAccount()
{
	document.getElementById("txtName").value = StringHelper.trim(document.getElementById("txtName").value);
	document.getElementById("txtBankName").value = StringHelper.trim(document.getElementById("txtBankName").value);
	document.getElementById("txtAccount").value = StringHelper.trim(document.getElementById("txtAccount").value);
	document.getElementById("txtCard").value = StringHelper.trim(document.getElementById("txtCard").value);
}
function validationAccount()
{
 _trimAccount();
  if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit")
  {
      if(document.getElementById('ddlNormal').selectedIndex==0)
   {
      alert("请选择用户！");
      document.getElementById('ddlNormal').focus();
      return false;
   }  
    if (document.getElementById('txtName').value =="")
    {
      alert("请输入中文姓名！");
      document.getElementById('txtName').focus();
      return false;
    }   
   if (document.getElementById('txtBankName').value =="")
    {
      alert("请输入银行名！");
      document.getElementById('txtBankName').focus();
      return false;
    }    
    if (document.getElementById('txtAccount').value =="")
    {
      alert("请输入账号！");
      document.getElementById('txtAccount').focus();
      return false;
    }    
    return true;
  }
  else
  {
    return true;
  }
}
function ClearAccount()
{
     document.getElementById('txtName').value="";  
     document.getElementById('txtAccount').value="";   
      document.getElementById('txtBankName').value="";   
     document.getElementById('txtCard').value="";    
     document.getElementById('ddlNormal').selectedIndex=0; 
     document.getElementById('ddlNormal').focus();
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
}
//月度限额
 function _trimBudget()
{
	document.getElementById("txtMonth1").value = StringHelper.trim(document.getElementById("txtMonth1").value);
	document.getElementById("txtMonth2").value = StringHelper.trim(document.getElementById("txtMonth2").value);
	document.getElementById("txtMonth3").value = StringHelper.trim(document.getElementById("txtMonth3").value);
	document.getElementById("txtMonth4").value = StringHelper.trim(document.getElementById("txtMonth4").value);
	document.getElementById("txtMonth5").value = StringHelper.trim(document.getElementById("txtMonth5").value);
	document.getElementById("txtMonth6").value = StringHelper.trim(document.getElementById("txtMonth6").value);
	document.getElementById("txtMonth7").value = StringHelper.trim(document.getElementById("txtMonth7").value);
	document.getElementById("txtMonth8").value = StringHelper.trim(document.getElementById("txtMonth8").value);
	document.getElementById("txtMonth9").value = StringHelper.trim(document.getElementById("txtMonth9").value);
	document.getElementById("txtMonth10").value = StringHelper.trim(document.getElementById("txtMonth10").value);
	document.getElementById("txtMonth11").value = StringHelper.trim(document.getElementById("txtMonth11").value);
	document.getElementById("txtMonth12").value = StringHelper.trim(document.getElementById("txtMonth12").value);
}
function validationBudget()
{
 _trimBudget();
  if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit")
  {
    if (document.getElementById('txtMonth1').value ==""||document.getElementById('txtMonth2').value ==""||document.getElementById('txtMonth3').value ==""||document.getElementById('txtMonth4').value ==""||document.getElementById('txtMonth5').value ==""||document.getElementById('txtMonth6').value ==""||document.getElementById('txtMonth7').value ==""||document.getElementById('txtMonth8').value ==""||document.getElementById('txtMonth9').value ==""||document.getElementById('txtMonth10').value ==""||document.getElementById('txtMonth11').value ==""||document.getElementById('txtMonth12').value =="")
    {
      alert("限额不能为空！");
      return false;
    }   
    return true;
  }
  else
  {
    return true;
  }
}
function ClearBudget()
{
     document.getElementById('txtCode').value="";  
     document.getElementById('txtJan1').value="0";  
     document.getElementById('txtFeb2').value="0";  
     document.getElementById('txtMar3').value="0";  
     document.getElementById('txtApr4').value="0"; 
     document.getElementById('txtMay5').value="0";
     document.getElementById('txtJune6').value="0";
     document.getElementById('txtJuly7').value="0";
     document.getElementById('txtAug8').value="0";
     document.getElementById('txtSep9').value="0";  
     document.getElementById('txtOct10').value="0";  
     document.getElementById('txtNov11').value="0";  
     document.getElementById('txtDec12').value="0";  
     document.getElementById('txtCode').focus();
     document.getElementById('ddlYear').selectedIndex=0; 
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
}
//Dimension
function ClearDimension()
{
     document.getElementById('txtCode').value="";  
     document.getElementById('txtDesc').value="";  
     document.getElementById('ddlCo').focus();
     document.getElementById('ddlType').selectedIndex=0; 
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
}
//Project
function ClearProject()
{
     document.getElementById('txtProCode').value="";  
     document.getElementById('txtProName').value="";  
     document.getElementById('txtProDesc').value="";  
     document.getElementById('ddlCo').focus();
     document.getElementById('ddlCC').selectedIndex=0; 
     document.getElementById('cmdAdd').disabled=false;
     document.getElementById('cmdEdit').disabled=true;
}
//电子公告
 function _trimNotice()
{
	document.getElementById("txtTitle").value = StringHelper.trim(document.getElementById("txtTitle").value);
	document.getElementById("txtPerson").value = StringHelper.trim(document.getElementById("txtPerson").value);
}
function validationNotice()
{
 _trimNotice();
  if(document.activeElement.id=="cmdAdd"||document.activeElement.id=="cmdEdit")
  {
        if(document.getElementById('txtTitle').value =="")
   {
      alert("请输入标题！");
      document.getElementById('txtTitle').focus();
      return false;
   }  
    if (document.getElementById('txtPerson').value =="")
    {
      alert("请输入发布人！");
      document.getElementById('txtPerson').focus();
      return false;
    }   
    return true;
  }
  else
  {
    return true;
  }
}
function showclose(objshow) {
var obj=document.getElementById(objshow);
if(obj.style.display=="none")
   obj.style.display="block";
else
   obj.style.display="none";
}
//确认框
function HandIn(Strs)
    {
        document.getElementById("divCmd").style.display="none";
        if(confirm(Strs)){ return true; }
        else { document.getElementById('divCmd').style.display="block"; return false; }
    }